Leetcode trie Practice Questions
Questionsβ
1. Implement Trie (Prefix Tree)β
Problem: Implement a trie with insert
, search
, and startsWith
methods.
Link: Implement Trie (Prefix Tree)
2. Add and Search Word - Data structure designβ
Problem: Design a data structure that supports adding new words and finding if a string matches any previously added string.
Link: Add and Search Word - Data structure design
3. Longest Word in Dictionaryβ
Problem: Find the longest word in the dictionary that can be built one character at a time by other words in the dictionary.
Link: Longest Word in Dictionary
4. Replace Wordsβ
Problem: Implement a function to replace all words in a sentence with their root forms using a dictionary of roots.
Link: Replace Words
5. Stream of Charactersβ
Problem: Design a class to search for strings in a stream of characters.
Link: Stream of Characters
6. Design Search Autocomplete Systemβ
Problem: Implement a search autocomplete system that supports inputting characters and returning the top 3 historical hot sentences.
Link: Design Search Autocomplete System
7. Prefix and Suffix Searchβ
Problem: Design a class that supports querying words with given prefix and suffix.
Link: Prefix and Suffix Search
8. Word Search IIβ
Problem: Given a 2D board and a list of words, find all words that can be formed by letters of the board.
Link: Word Search II
9. Map Sum Pairsβ
Problem: Implement a MapSum class with insert and sum methods, which sum all keys with a given prefix.
Link: Map Sum Pairs
10. Design Add and Search Words Data Structureβ
Problem: Design a data structure that supports adding new words and finding if a string matches any previously added string, with support for wildcards.
Link: Design Add and Search Words Data Structure
11. Palindrome Pairsβ
Problem: Given a list of unique words, find all pairs of distinct indices (i, j) such that the concatenation of words[i] and words[j] is a palindrome.
Link: Palindrome Pairs
12. Maximum XOR of Two Numbers in an Arrayβ
Problem: Find the maximum XOR of two numbers in an array.
Link: Maximum XOR of Two Numbers in an Array
13. Concatenated Wordsβ
Problem: Find all concatenated words in a given dictionary of words.
Link: Concatenated Words
14. Design Phone Directoryβ
Problem: Design a phone directory that initially has all phone numbers available to be assigned and supports checking availability, getting a number, and releasing a number.
Link: Design Phone Directory
15. Search Suggestions Systemβ
Problem: Given an array of products and a search word, design a system that suggests at most 3 products as you type each character of the search word.
Link: Search Suggestions System
16. Word Filterβ
Problem: Implement a WordFilter class that supports searching for words with a given prefix and suffix.
Link: Word Filter
17. Index Pairs of a Stringβ
Problem: Given a string text and an array of words, return all index pairs [i, j] so that the substring text[i...j] is in the array of words.
Link: Index Pairs of a String
18. Camelcase Matchingβ
Problem: Given a list of queries and a pattern, return a list of booleans where each boolean indicates whether the query matches the pattern.
Link: Camelcase Matching
19. Prefix and Suffix Searchβ
Problem: Implement a class that supports querying words with a given prefix and suffix (similar to question 7 but can be a different version or extension).
Link: Prefix and Suffix Search
20. Delete Duplicate Folders in Systemβ
Problem: Given a system of folders, delete all duplicate folders and return the list of unique folders.